package me.jiatao.baselibrary.ui.adapter

import android.content.Context
import android.widget.ImageView
import cn.bingoogolapple.bgabanner.BGABanner
import com.bumptech.glide.Glide
import me.jiatao.baselibrary.R

class BGABannerAdapter constructor(private val context: Context) :
    BGABanner.Adapter<ImageView, String> {

    val imgUrlList by lazy { mutableListOf<String>() }
    val tipList by lazy { mutableListOf<String>() }

    override fun fillBannerItem(
        banner: BGABanner, itemView: ImageView,
        model: String?, position: Int
    ) {
        Glide.with(context)
            .load(model)
            .placeholder(R.drawable.bg_placeholder)
            .error(R.drawable.bg_placeholder)
            .centerCrop()
            .dontAnimate()
            .into(itemView)
    }


    fun getItemSize(): Int {
        return imgUrlList.size
    }

    fun clearBannerList() {
        imgUrlList.clear()
        tipList.clear()
    }

    fun addBannerItem(imgUrl: String, tip: String) {
        imgUrlList.add(imgUrl)
        tipList.add(tip)
    }
}